package com.niodata.dp.core.resource.impl;

import com.niodata.dp.core.resource.AbstractResource;
import com.niodata.dp.core.resource.ResourceType;

public class TableResource extends AbstractResource {

  private final String tableName;
  private final String dbName;
  private final String dsName;

  public TableResource(ResourceType type, String content) {
    super(type, content);
    String[] ss = content.replaceAll(type.protocol() + "://", "").split("\\.");
    tableName = ss[2];
    dbName = ss[1];
    dsName = ss[0];
  }

  public TableResource(String dsName, String dbName, String tableName) {
    super(ResourceType.Table, dsName + "." + dbName + "." + tableName);
    this.dbName = dbName;
    this.tableName = tableName;
    this.dsName = dsName;
  }

  public String getTableName() {
    return tableName;
  }

  public String getDbName() {
    return dbName;
  }

  public String getDsName() {
    return this.dsName;
  }


}

